<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<html lang="cn" class="app">
<head>
    <title>后台管理 - 错误日志</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="icon" type="image/png" href="${contextPath}/icon.png">
    <link rel="apple-touch-icon-precomposed" href="${contextPath}/icon.png">
    <link rel="stylesheet" href="${ctxStatic}/js/jPlayer/jplayer.flat.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/animate.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/font.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/app.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/js/ztree/css/zTreeStyle.css" />
    <link rel="stylesheet" href="${ctxStatic}/js/layui/css/layui.css">
    <!--[if lt IE 9]>
    <script src="${ctxStatic}/js/ie/html5shiv.js"></script>
    <script src="${ctxStatic}/js/ie/respond.min.js"></script>
    <script src="${ctxStatic}/js/ie/excanvas.js"></script>
    <![endif]-->
</head>
<body>

<section class="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <!-- 引导开始 -->
            <ul class="breadcrumb">
                <li><a href="${ctx}/welcome"><i class="fa fa-home"></i> 主页</a></li>
                <li>系统设置</li>
                <li class="active">错误日志管理</li>
            </ul>
            <!-- 引导结束 -->
        </div>
    </div>

    <section class="panel panel-default">
        <%--操作区域 开始--%>
        <div class="row wrapper">
            <div class="col-sm-9 m-b-xs">

            </div>
            <%--搜索区域--%>
            <div class="col-sm-3">
                <div class="input-group">
                    <input id="searchKey" type="text" class="input-sm form-control" placeholder="输入用户名">
                    <span class="input-group-btn">
                        <button onclick="searchPage(1);" class="btn btn-sm btn-default" type="button">搜索</button>
                    </span>
                </div>
            </div>
        </div>
        <%--操作区域 结束--%>
        <%--列表开始--%>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th class="text-center" style="width:70px;"></th>
                    <th class="text-center">主键</th>
                    <th class="text-center">用户</th>
                    <th class="text-center">请求路径</th>
                    <th class="text-center">错误描述</th>
                    <%--<th class="text-center">错误详细内容</th>--%>
                    <%--<th class="text-center">请求agent</th>--%>
                    <%--<th class="text-center">请求参数</th>--%>
                    <%--<th class="text-center">请求body</th>--%>
                    <%--<th class="text-center">请求方式</th>--%>
                    <%--<th class="text-center">ip</th>--%>
                    <th class="text-center">错误时间</th>
                    <%--<th class="text-center">创建人</th>--%>
                    <%--<th class="text-center">创建时间</th>--%>
                    <th class="text-center" width="">操作</th>
                </tr>
                </thead>
                <tbody id="tplView">

                </tbody>
            </table>
        </div>
        <%--列表结束--%>
        <%--分页开始--%>
        <footer class="panel-footer">
            <div class="row">
                <div id="page" class="col-sm-12 text-right text-center-xs"></div>
            </div>
        </footer>
        <%--分页结束--%>

    </section>

</section>


</body>
<script src="${ctxStatic}/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="${ctxStatic}/js/bootstrap.js"></script>
<!-- App -->
<script src="${ctxStatic}/js/app.js"></script>
<script src="${ctxStatic}/js/slimscroll/jquery.slimscroll.min.js"></script>
<script src="${ctxStatic}/js/app.plugin.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/tools.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/page/paging.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/layer/layer.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/tmpl/jquery.tmpl.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/layui/layui.all.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/table2excel/jquery.table2excel.js"></script>
<script id="tplHtml" type="text/x-jquery-tmpl">
    {{if results && results.length>0 }}
        {{each results}}
        <tr>
            <td class="text-center" ><a href="javascript:openView('{{= id }}')">{{= ($index+1)+(pageNo-1)*10}}</a></td>
            <td class="text-center">{{= id}}</td>
            <td class="text-center">{{= username}}</td>
            <td class="text-center">{{= uri}}</td>
            <td class="text-center">{{= errorMessage}}</td>
            <%--<td class="text-center">{{= errorContent}}</td>--%>
            <%--<td class="text-center">{{= userAgent}}</td>--%>
            <%--<td class="text-center">{{= requestParam}}</td>--%>
            <%--<td class="text-center">{{= requestBody}}</td>--%>
            <%--<td class="text-center">{{= requestMethod}}</td>--%>
            <%--<td class="text-center">{{= ip}}</td>--%>
            <td class="text-center">{{= errorTime}}</td>
            <%--<td class="text-center">{{= createBy}}</td>--%>
            <%--<td class="text-center">{{= createDateStr}}</td>--%>
            <td class="text-center">
                <shiro:hasPermission name="sys:elog:update">
                <a href="javascript:;" onclick="openView('{{= id }}')" class="btn btn-sm btn-info">查看</a>
                </shiro:hasPermission>
                <shiro:hasPermission name="sys:elog:delete">
                <a href="javascript:deleteData('{{= id }}')" title="删除" class="btn btn-sm btn-danger">删除</a>
                </shiro:hasPermission>
            </td>
        </tr>
        {{/each}}
    {{else}}
        <tr><td colspan="7" class="text-center" >暂无数据</td></tr>
    {{/if}}
</script>
<script>
    $(function(){
        //加载分页数据
        searchPage(1);
    })
    /** 查询分页数据 @author gaoyuan */
    function searchPage(num){
        var searchKey = $("#searchKey").val();
        var loadingLayer = layer.load(1, {shade: [0.1,'#fff']});//loading
        $.ajax({
            type: 'post',
            url: '${ctx}/sys/elog/getPage.json?timeStamp='+new Date().getTime(),
            dataType:"json",
            data: {"pageNo":num,"pageSize":$("#paging_js_page_size").val(),"searchKey":searchKey},
            success: function (data) {
                layer.close(loadingLayer);
                var page = data.data;
                $( "#tplView" ).empty();
                $( "#tplHtml" ).tmpl( data.data ).appendTo( "#tplView" );

                //分页
                $("#page").paging({
                    pageNo:page.pageNo,
                    totalPage: page.totalPage,
                    totalSize: page.totalRecord,
                    callback: function(num) {
                        searchPage(num);
                    }
                })
            },error:function(){
                layer.close(loadingLayer);
            }
        });
    }

    /** 打开详情页面 @author gaoyuan */
    function openView(id){
        var index = layer.open({
            type: 2,
//            skin: 'layui-layer-rim', //加上边框
            area: ['80%', '80%'], //宽高
            title: "错误日志详情",
            content: "${ctx}/sys/elog/view?id="+id,
            cancel: function(index){
                layer.close(index);
            }
        });
    }

    /** 删除数据 @author gaoyuan */
    function deleteData(id){
        layer.confirm('确认删除此数据吗？', {
            btn: ['确认删除','取消'] //按钮
        }, function(){
            var loadingLayer = layer.load(1, {shade: [0.1,'#fff']});//loading
            $.ajax({
                type: 'post',
                url: '${ctx}/sys/elog/delete.json?timeStamp='+new Date().getTime(),
                dataType:"json",
                data: {"id":id},
                success: function (data) {
                    layer.close(loadingLayer);
                    showMsg(data.desc);
                    searchPage(1);
                },error:function(){
                    layer.close(loadingLayer);
                    alert("程序异常");
                }
            });
        }, function(){

        });
    }
</script>
</html>
